package com.xb.loan.cashier.biz.job;

import com.xb.loan.cashier.biz.dao.bean.CashierPayChannel;
import com.xb.loan.cashier.biz.task.ThirdAccountEncashTask;
import com.xb.loan.cashier.biz.task.alipay.AlipayWapAccountEncashTask;
import com.xb.loan.cashier.service.constant.ICashierEnumConst;
import com.xb.loan.util.qrtz.task.AbstractSimpleTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 第三方提现对账任务
 */
public class ThirdAccountEncashChannelJob extends AbstractSimpleTask {
    private static final Logger log = LoggerFactory.getLogger(ThirdAccountEncashChannelJob.class);

    private CashierPayChannel channel;  // 第三方渠道
    private String accountDayThird;     // 第三方对账日期
    
    @Override
    public void run() {
    	log.info("ThirdAccountEncashChannelJob run 第三方提现渠道对账开始");
        ThirdAccountEncashTask task = null;
        if(channel.getPaychannelType()== ICashierEnumConst.CashierPayChannelType.ALIPAY.getType()){
            AlipayWapAccountEncashTask temp = getSpringBean("alipayWapAccountEncashTask");
            temp.setDay(accountDayThird);
            temp.setPayChannelId(channel.getPayChannelId());
            task = temp;
        }// 其他第三方渠道
        if(task==null){
            log.warn("Model={0} payChannelId={1} paychannelType={2} msg={3}", new Object[]{"cashier", channel.getPayChannelId(), channel.getPaychannelType(), "任务类型不存在！"});
            throw new RuntimeException("Model={cashier} payChannelId={"+channel.getPayChannelId()+"} paychannelType={"+channel.getPaychannelType()+"} msg={第三方提现对账任务类型不存在！}");
        }
        task.execute();// 同步执行
    }
    public void setChannel(CashierPayChannel channel) {
        this.channel = channel;
    }
    public void setAccountDayThird(String accountDayThird) {
        this.accountDayThird = accountDayThird;
    }

}
